package com.zw.yzk.kabu.data.repository;

import com.zw.yzk.kabu.data.network.ServiceGenerator;
import com.zw.yzk.kabu.data.network.entity.UnreadMessageEntity;
import com.zw.yzk.kabu.data.network.service.GetUnreadMessageCountService;
import com.zw.yzk.kabu.data.network.task.Task;

import javax.inject.Inject;

import rx.Observable;
import rx.functions.Func1;

/**
 * Created by zhanwei on 2016/12/24.
 */

public class GetUnreadMessageCountRepository extends CommonRepository {

    @Inject
    public GetUnreadMessageCountRepository() {

    }

    @Override
    protected Observable connectServer(Task task) {
        GetUnreadMessageCountService service = ServiceGenerator.createService(GetUnreadMessageCountService.class);

        return service.getUnreadCount(task.userId, task.accessToken);
    }

    @Override
    protected Func1<UnreadMessageEntity, Observable> getServerData() {
        return new Func1<UnreadMessageEntity, Observable>() {
            @Override
            public Observable call(UnreadMessageEntity entity) {
                return Observable.just(entity);
            }
        };
    }

}
